// 时间格式化
export const timeFormat = value => {
  let obj = {
    day: 1000 * 60 * 60 * 24,
    hour: 1000 * 60 * 60,
    min: 1000 * 60,
    s: 1000,
    ms: 1
  };

  for (let i in obj) {
    if (Number(value) >= obj[i]) {
      return (Number(value) / obj[i]).toFixed(2) + ` ${i}`;
    }
  }
  return "0 ms";
};

// 单位
export const getByte = value => {
  if (!value) return "";
  let obj = {
    GB: 1024 * 1024 * 1024,
    MB: 1024 * 1024,
    KB: 1024,
    Byte: 1
  };
  for (let i in obj) {
    if (Number(value) >= obj[i]) {
      return (Number(value) / obj[i]).toFixed(2) + ` ${i}`;
    }
  }
  return "0 Byte";
};
